<template>
    <div>
        <h1>注册</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>账号</td>
                    <td>
                        <input type="text" v-model="date.userName">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="date.userPwd">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="注册" @click="addd">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import axios from 'axios';
const routher = useRouter()
const addd=()=>{
    axios.post("https://localhost:7258/api/User/AddUser",date.value).then(res=>{
        if(res.data>0){
            alert("注册成功")
            routher.push({path:"/LoginUser"})
        }
        else{
            alert("注册失败")
        }
    })
}
const date=ref({
  "userId": 0,
  "userName": "",
  "userPwd": ""
})
</script>

<style scoped>

</style>